cmake_minimum_required(VERSION 3.10)
project(sample1)

set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(COMPILER_HEADER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../compiler/api)

# 头文件搜索目录
include_directories(${SRC_DIR} ${COMPILER_HEADER_PATH})

# 源文件
file(GLOB_RECURSE CORE_SOURCE_FILES
        ${SRC_DIR}/*.*
)

# 链接结绳编译器库文件
function(add_tiec_library)
    set(LIB_PATH)
    if (ANDROID)
        add_library(tiec_lib SHARED IMPORTED)
        set(LIB_PATH ${CMAKE_SOURCE_DIR}/compiler/lib/android/${CMAKE_ANDROID_ARCH_ABI}/libtiec.so)
    elseif (WIN32)
        add_library(tiec_lib STATIC IMPORTED)
        set(LIB_PATH ${CMAKE_SOURCE_DIR}/compiler/lib/windows/libtiec.dll.a)
    endif ()
    set_target_properties(tiec_lib PROPERTIES IMPORTED_LOCATION ${LIB_PATH})
    target_link_libraries(sample1 tiec_lib)
endfunction()

add_library(sample1 SHARED ${CORE_SOURCE_FILES})
add_tiec_library()